<!--
 * Copyright © 2023
 * @Author: zhangxiang
 * @Date: 2023-04-06 17:14:11
 * @LastEditors: zhangxiang
 * @LastEditTime: 2023-08-21 10:41:34
 * @Description:
 *
-->

<template>
  <div class="overall-state-ctn">
    <div class="title">资源总况</div>
    <div class="content">
      <div v-for="(item, index) in allInfo" :key="index" class="item">
        <div :class="['num', item.key === '接入云商总数' ? 'special' : '']">
          {{ item.val }}
        </div>
        <div class="text">{{ item.key }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { getPlatformInfos } from '@/api/cnap/situation'

export default {
  name: 'OverallState',
  props: {
    overall: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      extra: []
    }
  },
  computed: {
    allInfo() {
      return this.overall.concat(this.extra)
    }
  },
  watch: {},
  created() {
    this.getData()
  },
  mounted() {},
  methods: {
    /**
     * @description: 获取数据
     * @return {*}
     */
    getData() {
      getPlatformInfos().then((res) => {
        if (res.data) {
          this.extra.push({
            key: '集群总数',
            val: res.data.clusterNum || '0'
          })
          this.extra.push({
            key: '服务总数',
            val: res.data.microSvcNum || '0'
          })
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
@import "@/assets/css/common.less";
@import "@/assets/css/font.less";
.overall-state-ctn {
  width: 814px;
  height: 130px;
  background: url("~@/assets/imgs/situation/bg_title_overall.png") no-repeat;
  background-size: 100% 100%;

  .title {
    .textStyle(20px , 600, #03d3ff);
    line-height: 26px;
    text-align: center;
    margin-top: 10px;
  }

  .content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 0 40px;
    margin-top: 8px;

    .item {
      display: flex;
      flex-direction: column;
      align-items: center;

      .num {
        .textStyle(46px, 400, #03f9ff);
        font-family: "DIGITAL-Regular";
        line-height: 56px;
        text-shadow: 0px 0px 9px rgba(3, 249, 255, 0.85);

        &.special {
          color: #90ff03;
          text-shadow: 0px 0px 9px rgba(144, 255, 3, 0.85);
        }
      }

      .text {
        .textStyle(14px, 500, #B0CFE8);
        line-height: 20px;
      }
    }
  }
}
</style>
